<?php
$this->headLink()->appendStylesheet($this->baseUrl('css/dhtmlXTree.css'));

$this->headScript()->appendFile($this->baseUrl('js/dhtmlx/dhtmlXProtobar.js'))
				   ->appendFile($this->baseUrl('js/dhtmlx/dhtmlXMenuBar.js'))
				   ->appendFile($this->baseUrl('js/dhtmlx/dhtmlXMenuBar_cp.js'))
				   ->appendFile($this->baseUrl('js/dhtmlx/dhtmlXCommon.js'))
				   ->appendFile($this->baseUrl('js/dhtmlx/dhtmlXTree.js'))
				   ->appendFile($this->baseUrl('js/dhtmlx/dhtmlXGrid.js'))
				   ->appendFile($this->baseUrl('js/dhtmlx/dhtmlXGridCell.js'))
				   ->appendFile($this->baseUrl('js/dhtmlx/dhtmlXGrid_excell_link.js'))
				   ->appendFile($this->baseUrl('js/modules/roles.js'));

$rutaimg=$this->baseUrl('img/arbol/');
$pagina="/public/roles/funcionalidades/arbol";
if (isset($this->codrol) && !empty($this->codrol)) {
	$params = App_Util_SafeUrl::encriptar(array("codigo"=>$this->codrol),true);
	 $pagina.="/{$params}";
}

echo $this->navegacion($this->nav);
$perfil = App_Perfil::getInstance();
$perfil->cargar("ADMIN_ROLES");
if (!$perfil->modificar()) $this->form->makeStatic();
?>
<script type="text/javascript">
function cargarCodigos(objForm) {
	objForm.codigos.value=tree.getAllChecked();
	return true;
}

</script>
<div style="width: 700px;" class="center-block" >
<form id="info_rol" name="formapara" action="<?= $this->url();?>" onsubmit="cargarCodigos(this);" method="post" encType="multipart/form-data">
<table width="100%" align="center">
	<tbody>
		<tr>
			<td valign=top>
    			<?php
				echo $this->form;
				?>
			</td>
	    </tr>
	    <tr>
			<td vAlign=top >
			<table width="98%" align="center" class="iceDatTbl zebra">
				<tr class="TABLA_ENCABEZADO_SACES">
					<th align="left">Funcionalidades disponibles</th>
				</tr>
			</table>
			<table width="98%" align=center>
				<tr align="left">
					<td><a href="javascript:tree.openAllItems(0);">
						<img src="<?php echo "{$rutaimg}folderOpen.gif"; ?>" />&nbsp;Expandir todos</a>
						&nbsp;&nbsp;&nbsp;
						<a href="javascript:tree.closeAllItems(0);">
						<img src="<?php echo "{$rutaimg}folderClosed.gif"; ?>" />&nbsp;Cerrar todos</a>
					</td>
				</tr>
				<tr class="last" align="left">
					<td>
					<div id="treeboxbox_tree"
						style="width: 250; height: 218; background-color: #f5f5f5; border: 1px solid Silver; overflow: auto;"></div>
					</td>
				</tr>
			</table>
			</td>
		</tr>
	</tbody>
</table>
</form>
<script>
	tree=new dhtmlXTreeObject("treeboxbox_tree","80%","80%",0);
	tree.setImagePath("<?php echo $rutaimg;?>");
	tree.enableCheckBoxes(1);
	tree.enableThreeStateCheckboxes(true);

	tree.loadXML("<?php echo $pagina?>");
	tree.enableTreeLines(true);
	tree.setImageArrays("plus","plus2.gif","plus3.gif","plus4.gif","plus.gif","plus5.gif");
	tree.setImageArrays("minus","minus2.gif","minus3.gif","minus4.gif","minus.gif","minus5.gif");
	tree.setStdImages("hoja.gif","folderOpen.gif","folderClosed.gif");
	
</script>
</div>